#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const int N=2e5+10;
#define INF 0x3f3f3f3f;
typedef long long int ll;
#define close(); std::ios::sync_with_stdio(false);cin.tie(0),cout.tie(0);
//----------------------------------------------------------------------------//
int a[N];
void solve() 
{
  int n;
  cin >> n;
  for(int i=0;i<n;i++) cin>>a[i];
 
 
  int64_t ans = 0;
  for (int i = 0, j = 0; i < n; i++) {
    while (j < n && a[j] - (j - i) - 1 >= 0) j++;
    ans += j - i;
  }
  cout << ans << "\n";
}
int main()
{
	close();
	int T; cin>>T;
	while (T--) solve();
	return 0;
}

